
class Aio::Module::OutputStyle::Brief < Aio::Module::OutputStyle

  include Aio::Ui::Verbose
  include Aio::Device

  def initialize
    super({
      :author		=> "Elin",
      :description	=> "这个模块是用来生成一个极其简单的列表",
      :file_suffix	=> "txt",
    })

    @report = []

  end

  def generate
    file = File.new(output_file, "w+")

    device_manager.devices.each_key do |device_name|
      device_klass = device_manager[device_name]

      generate_biref(device_klass)
    end

    file.write(@report.join("\n"))
  ensure
    file.close
  end

  def generate_biref(klass)
    hash = {}
    hash[:name] =  klass.device_name
    hash[:uptime] = klass.uptime
    hash[:cpu] = klass.cpu_percent
    hash[:mem] = klass.memory_percent
    set_list(hash)
  end

  def set_list(hash)
    str = format("%20s | %s | %s | %s", hash[:name], hash[:uptime], hash[:cpu], hash[:mem])
    @report << str
  end
end
